<script lang="ts" setup>
import { ref } from 'vue';
import BarcodeGenerator from '../../components/BarcodeGenerator.vue';
import QRCodeGenerator from '../../components/QRCodeGenerator.vue';
import TopNav from '../../components/TopNav.vue';
import { useRouter } from 'vue-router';
const router = useRouter()
const text = ref('132132179878')
const text1=ref('http://localhost:8080/pron')
const flag = ref(true)
const show = ref(false);
const getswi = () => {
    show.value = true;
    console.log(1111);
    // flag.value = !flag.value
}
const ling = () => {
    flag.value = true
    show.value = false
}
const Bank = () => {
    flag.value = false
    show.value = false
}
const data = ref([
    {
        id: 1,
        name: '二维码收款',
        icon: 'cash-o'
    },
    {
        id: 2,
        name: '赞赏码',
        icon: 'good-job'
    },
    {
        id: 3,
        name: '群收款',
        icon: 'newspaper'
    },
    {
        id: 4,
        name: '面对面红包',
        icon: 'gift-card'
    },
    {
        id: 5,
        name: '向银行卡或手机号转账',
        icon: 'exchange'
    },
])

//跳转
const Payment = (item) => {
    if (item.name === '二维码收款') {
        router.push('/qrcode')
    }
}
</script>

<template>
    <div class="top">
        <TopNav title="收付款" style="color: #fff;width: 95%;margin: 0 auto;"></TopNav>
        <div class="fu">
            <div class="fu1">
                <p style="color: rgb(92, 229, 71);">
                    <van-icon name="scan" size="20" />
                    <span style="padding-left: 10px;">付款码</span>
                </p>
                <p>
                    <van-icon name="ellipsis" size="20" />
                </p>
            </div>
            <div class="fu2">
                <p>优先使用零钱付款</p>
                <BarcodeGenerator :text="text"></BarcodeGenerator>
                <QRCodeGenerator :text1="text1"></QRCodeGenerator>
            </div>
            <div class="fu3">
                <div class="fu33">
                    <span>优先付款方式</span>
                    <span @click="getswi">更改</span>
                </div>

                <div class="fu31">
                    <div class="fu311" v-if="flag ? true : false">
                        <p>零钱</p>
                        <p><van-icon name="success" color="rgb(138, 244, 142)" /></p>
                    </div>
                    <div class="fu312" v-else>
                        <p>
                        <p style="font-size: 15px;padding-bottom: 5px;">邯郸银行储蓄卡</p>
                        <p>**** **** **** 1111</p>
                        </p>
                        <p><van-icon name="success" color="rgb(138, 244, 142)" /></p>
                    </div>
                </div>
            </div>

            <!-- 切换更改 -->
            <van-popup v-model:show="show" closeable close-icon-position="top-left" round position="bottom"
                :style="{ height: '30%', background: '#303030' }">
                <div class="popup">
                    <p style="padding-top: 10px;">选中优先付款方式</p>
                    <div>
                        <span
                            style="font-size: 13px;color: #ccc;padding-top: 10px;">优先使用所选付款方式付款,如付款失败将尝<br />试使用其他付款方式完成付款</span>
                    </div>
                    <div class="popup2">
                        <p @click="ling">
                            <span>零钱(剩余￥100)</span>
                            <span><van-icon name="success" v-if="flag ? true : false"
                                    color="rgb(138, 244, 142)" /></span>
                        </p>
                        <p @click="Bank">
                            <span>邯郸银行 储蓄卡(1111)</span>
                            <span><van-icon name="success" v-if="flag ? false : true"
                                    color="rgb(138, 244, 142)" /></span>
                        </p>
                    </div>
                </div>
            </van-popup>

        </div>
        <div class="fu444">
            <div class="fu4">
                <ul>
                    <li v-for="item in data" @click="Payment(item)">
                        <p>
                            <span>
                                <van-icon :name="item.icon" />
                            </span>
                            <span style="padding-left: 10px;">
                                {{ item.name }}
                            </span>
                        </p>
                        <p>
                            <van-icon name="arrow"/>
                        </p>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</template>

<style scoped>
.top {
    width: 100%;
    height: 100%;
    background-color: rgb(92, 229, 71);
    /* overflow: hidden; */
}

.fu444 {
    width: 100%;
    background-color: rgb(92, 229, 71);

}

.fu {
    width: 95%;
    /* height: 420px; */
    background-color: #fff;
    margin: 0 auto;
    border-radius: 5px;
    padding-bottom: 1px;
}

.fu1 {
    display: flex;
    width: 95%;
    height: 50px;
    border-bottom: 1px solid #ccc;
    justify-content: space-between;
    padding-top: 10px;
    margin: 0 auto;

}

.fu2 {
    text-align: center;
    margin-top: 20px;
}

.fu2 p {
    font-size: 13px;
    color: #c7c7c7;
}

.fu33 {
    display: flex;
    width: 95%;
    justify-content: space-between;
    margin: 0 auto;
}

.fu31 {
    width: 100%;
    margin-top: 10px;
    margin-bottom: 10px;
}

.fu311 {
    width: 95%;
    display: flex;
    justify-content: space-between;
    margin: 0 auto;
    align-items: center;
    height: 40px;
    background-color: antiquewhite;
    padding: 0 10px;
    border-radius: 5px;
}

.fu312 {
    width: 95%;
    display: flex;
    justify-content: space-between;
    margin: 0 auto;
    align-items: center;
    height: 60px;
    background-color: rgb(188, 227, 235);
    padding: 0 10px;
    border-radius: 5px;

}

.fu4 {
    color: #f0eeee;
    width: 95%;
    height: 270px;
    margin: 0 auto;
    background-color: rgb(92, 229, 71);
}

.fu4 ul {
    width: 100%;

    border: 1px solid #f8f6f6;
    margin-top: 10px;
    border-radius: 5px;
    text-align: center;

}

.fu4 ul li {
    width: 98%;
    margin-left: 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    border-bottom: 1px solid #eeecec;

}

.popup {
    text-align: center;
    color: #fff
}

.popup2 {
    width: 95%;
    margin: 0 auto;
    margin-left: 25px;
    margin-top: 20px;
}

.popup2 p {
    display: flex;
    justify-content: space-between;
    width: 90%;
    height: 40px;
    line-height: 40px;
    border-top: 1px solid #ccc;
    border-bottom: 1px solid #ccc;
}
</style>
